// pages/mySelf/mySelf.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		result: '',
		nickName: '',
		avatarUrl: '',
		canIUse: wx.canIUse('button.open-type.getUserInfo'),
		pageNumber: 0
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		let that = this
		wx.getSetting({
			success(res) {
				if (res.authSetting['scope.userInfo']) {
					wx.getUserInfo({
						success: function (res) {
							var userInfo = res.userInfo;
							that.setData({
								nickName: userInfo.nickName,
								avatarUrl: userInfo.avatarUrl
							})
						}
					});
				} else {
					that.setData({
						result: null
					})
				}
			}
		})

	},
	bindGetUserInfo(e) {
		console.log(e.detail.userInfo.nickName)
		var that = this;
		that.setData({
			result: 'ok', // 结果
			nickName: e.detail.userInfo.nickName, // 微信昵称
			avatarUrl: e.detail.userInfo.avatarUrl, // 微信头像
		})
	},
	goManger() {
		let currentCount = this.data.pageNumber;
		currentCount++;
		this.setData({
			pageNumber: currentCount
		});
		if (currentCount == 5) {
			wx.navigateTo({
				url: '/pages/mangerMessage/mangerMessage',
			})
		}
	},
	callTelephone() {
		wx.showModal({
			title: '联系电话',
			content: '13347404480',
			showCancel:false
		})
	},
	myExchange() {
		wx.navigateTo({
			url: '/pages/myExchange/myExchange',
		})
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {
		this.setData({
			pageNumber: 0
		})
	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {

	}
})